import { isArray } from '@tarojs/shared';
import { getCurrentPages } from '@tarojs/taro';

export const getWxPages = function () {
    try {
        let currentPages = getCurrentPages();
        if (isArray(currentPages) && currentPages.length > 0) {
            const currentPage = currentPages[currentPages.length - 1];
            if (currentPage) {
                return currentPages;
            }
        }

        return [];
    } catch {
        throw new Error('没有兼容getCurrentPages方法无法获取页面栈');
    }
};
